jQuery(function($) {
    var swiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        effect: 'cube',
        grabCursor: true,
        cube: {
            shadow: true,
            slideShadows: true,
            shadowOffset: 30,
            shadowScale: 0.94
        }
    });
    $.ajax({
        url: "json/index.json",
        type: "GET",
        dataType: 'json',
        success: function(data) {

            var str1 = '',
                str2 = '';
            $.each(data.data1, function(i, v) {
                str1 += '<dl><dd><img src="' + v.imgUrl + '"></dd><dt><p>' +
                    v.title + '</p></dt></dl>';
            })
            $.each(data.data2, function(i, v) {

                str2 += '<dl><dd><img src="' + v.imgUrl + '"></dd><dt><p>' +
                    v.title + '</p></dt></dl>';
            })
            $(".dl1").html(str1);
            $(".dl2").html(str2);

        }
    })
    $.ajax({
        type: 'GET',
        url: 'json/new.json',
        dataType: 'json',
        success: function(data) {
            var str3 = template("temp1", { list1: data });
            $('.shopList').html(str3);

        }
    });
    window.onscroll = function() {
        var scrTop = document.body.scrollTop;
        var height = $('.site').innerHeight();
        if (scrTop > height) {
            $('.search').css('background', 'linear-gradient(90deg,rgb(0, 170, 255), rgb(0, 134, 255))').css('position', 'fixed').css('top', '0')
        } else {
            $('.search').css('position', 'relative')
        }
    }
    $('.city').on('click', function() {
        $('.box2').show().animate({ 'left': 0 }, 500, function() {
            $('.box1').hide()
        })
    })
    $('#back').on('click', function() {
        $('.box1').show();
        $('.box2').animate({ 'left': '100%' }, 500, function() {
            $('.box2').hide()
        })
    })
    $('.foot').on('click', 'section', function() {
        $(this).addClass('foot_active').siblings().removeClass('foot_active')
    })
});